<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html lang="zh">
 <head>
  <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
  <meta content="2018-10-23T06:18:10.521000000" name="created"/>
  <meta content="2023-12-12T09:31:21" name="changed" translator="gocpicnic"/>
  <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  <meta content="zh" http-equiv="Content-Language"/>
  <title>
   <!-- Library Class -->
   图书馆课
  </title>
  <link href="../../style.css" rel="stylesheet" type="text/css"/>
 </head>
 <body>
  <div class="codediv">
   <h1>
    <!-- Library Class -->
    图书馆课
   </h1>
   <p>
    <!-- The access point for the JAR library is a class that extends the <code>Library</code> class. The library's main job is to list the tools that are available through the library; most often, the tools are all tools to add the various components defined - that is, instances of the <code>AddTool</code> class working with different component factories. -->
    JAR 库的访问点是一个扩展
    <code>
     Library
    </code>
    类的类。 库的主要工作是列出通过库可用的工具； 大多数情况下，这些工具都是用于添加定义的各种组件的工具 - 即与不同组件工厂一起使用的
    <code>
     AddTool
    </code>
    类的实例。
   </p>
   <h2>
    Components
   </h2>
   <pre>package com.cburch.gray;

import java.util.Arrays;
import java.util.List;

import com.cburch.logisim.tools.AddTool;
import com.cburch.logisim.tools.Library;

/** The library of components that the user can access. */
public class Components extends Library {
    /** The list of all tools contained in this library. Technically,
     * libraries contain tools, which is a slightly more general concept
     * than components; practically speaking, though, you'll most often want
     * to create AddTools for new components that can be added into the circuit.
     */
    private List&lt;AddTool&gt; tools;
    
    /** Constructs an instance of this library. This constructor is how
     * Logisim accesses first when it opens the JAR file: It looks for
     * a no-arguments constructor method of the user-designated class.
     */
    public Components() {
        tools = Arrays.asList(new AddTool[] {
                new AddTool(new GrayIncrementer()),
                new AddTool(new SimpleGrayCounter()),
                new AddTool(new GrayCounter()),
        });
    }
    
    /** Returns the name of the library that the user will see. */ 
    public String getDisplayName() {
        return "Gray Tools";
    }
    
    /** Returns a list of all the tools available in this library. */
    public List&lt;AddTool&gt; getTools() {
        return tools;
    }
}
</pre>
   <p>
    <b>
     Next:
    </b>
    <a href="simpctr.html">
     Simple Gray Code Counter
    </a>
    .
   </p>
  </div>
 </body>
</html>
